package com.four.hospital.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.four.common.utils.R;
import com.four.hospital.entity.User;
import com.four.hospital.service.UserService;
import com.four.hospital.vo.DoctorAndUserVo2;
import com.four.hospital.vo.UserVo;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.net.HttpCookie;

/**
 * @Author:wsy
 * @Date: 2022/01/07/20:35
 * @Description
 */
@RestController
@RequestMapping("hospital/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 患者管理列表、分页、精准
     *
     * @param vo
     * @param page
     * @param size
     * @return
     */
    @PostMapping("/list")
    public IPage<User> list(@RequestBody UserVo vo,
                            @RequestParam(value = "page", defaultValue = "1") Integer page,
                            @RequestParam(value = "size", defaultValue = "3") Integer size) {
        return userService.userList(vo, page, size);
    }

    /**
     * 患者管理详情查
     *
     * @return
     */
    @GetMapping("/findList/{userId}")
    public DoctorAndUserVo2 findList(@PathVariable("userId") Integer userId) {

        return userService.findList(userId);
    }

    /**
     * 获取验证码
     *
     * @param userPhone
     * @return
     */
    @GetMapping("/getYzmByPhone/{userPhone}")
    public R getYzmByPhone(@PathVariable("userPhone") String userPhone) {

        return userService.getYzmByPhone(userPhone);
    }

    /**
     * 登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody User user) {

        return userService.login(user);
    }

    /**
     * 根据手机号查询
     * @param userPhone
     * @return
     */
    @GetMapping("/findByuserPhone/{userPhone}")
    public R findByUserPhone(@PathVariable("userPhone")String userPhone){
        userService.findByUserPhone(userPhone);
        return R.ok();
    }
}
